Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Creating a dynamic browse and customizing its display

The initializeObject procedure creates a dynamic browse whose columns are filled in when you select fields for a table. It also defines a ROW-DISPLAY trigger that fires as each row in the browse is displayed:

 /* Create the dynamic browser here */ 
  CREATE BROWSE hBrowse 
    ASSIGN 
      ROW = 8 
      COLUMN = 2 
      WIDTH = 86 
      DOWN = 12 
      VISIBLE = NO 
      ROW-MARKERS = NO 
      SEPARATORS = YES 
      COLUMN-RESIZABLE = YES 
      COLUMN-MOVABLE = YES 
      NO-VALIDATE = YES 
      FRAME = FRAME {&FRAME-NAME}:HANDLE 
/* The trigger clause is here to do the alternate line color in the broswe */ 
    TRIGGERS: 
      ON ROW-DISPLAY PERSISTENT RUN rowDisplay IN THIS-PROCEDURE. 
    END TRIGGERS 
  . 

The ROW-DISPLAY event lets you intercept the display of each row in the browse to change colors, formats, or calculated values. If you look at the trigger procedure that handles that ROW-DISPLAY event, you see that it is responsible for alternating the browse rows between white and gray. The lRow logical variable is defined in the Definitions section for the main procedure block so that its value is maintained between calls to rowDisplay:

/* Static toggle switch for the line color */ 
DEFINE VARIABLE lRow AS LOGICAL NO-UNDO. 

The rowDisplay procedure sets foreground and background colors depending on the setting of lRow:

/* If the toggle is yes */ 
   IF lRow THEN 
     ASSIGN 
      iBGColor = 8  /* Set the background color grey */ 
      iFGColor = 0  /* and foreground color black * 
    . 
  ELSE 
     ASSIGN 
      iBGColor = 15 /* else background color white */ 
      iFGColor = 0  /* and foreground color black */ 
    . 

It then assigns these colors for each cell in the row. There’s no attribute that lets you do this for the entire row at once:

  /* Iterate through the list of browse columns */ 
  DO iCount = 1 TO NUM-ENTRIES(cBrwsCols): 
    /* Convert the string value to a handle */ 
    hBrwsCol = WIDGET-HANDLE(ENTRY(iCount,cBrwsCols)). 
    IF VALID-HANDLE(hBrwsCol) THEN 
    DO: 
      hBrwsCol:BGCOLOR = iBGColor. /* Set the cell's background color */ 
      hBrwsCol:FGCOLOR = iFGColor. /* and it's foreground color */ 
    END. 
  END. 

Finally, it reverses the value of lRow in preparation for the next call:

lRow = NOT lRow. /* Set the toggle opposite */ 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095